﻿using HrEFCore;
using HrIService;
using Microsoft.EntityFrameworkCore;

namespace HrService
{
	public class CFFKService : ICFFKService
	{
		private readonly MyDbContext myDbContext;
		public CFFKService(MyDbContext myDbContext)
		{
			this.myDbContext = myDbContext;
		}

		

		//删除
		public async Task<int> CFFKDelAsync(short FfkId)
		{
			CFFK cffk = await myDbContext.CFFK.FindAsync(FfkId);
			if (cffk == null)
			{
				return 0;
			}
			myDbContext.CFFK.Remove(cffk);
			return await myDbContext.SaveChangesAsync();
		}
		//添加
		public async Task<int> CFFKInsertAsync(CFFK c)
		{
			//CFFK cFFK = new CFFK()
			//{
			//	FfkId = c.FfkId,
			//	FirstKindId = c.FirstKindId,
			//	FirstKindName = c.FirstKindName,
			//	FirstKindSalaryId = c.FirstKindSalaryId,
			//	FirstKindSaleId = c.FirstKindSaleId,
			//};
			myDbContext.CFFK.AddAsync(c);
			return await myDbContext.SaveChangesAsync();
		}
		//查看
		public async Task<List<CFFK>> CFFKSelectAsync()
		{
			return await myDbContext.CFFK.ToListAsync();
		}
		//修改
		public async Task<int> CFFKUpdateAsync(CFFK cffk)
		{
			myDbContext.CFFK.Update(cffk);
			return await myDbContext.SaveChangesAsync();
		}
		//根据id查询
		public async Task<CFFK> CFFKByIdAsync(short FfkId)
		{
            return await myDbContext.CFFK.FindAsync(FfkId);
		}
	}
}
